package obj;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Timer;

import org.newdawn.slick.Animation;
import org.newdawn.slick.SlickException;

import play.Things;

/**
 * Boss enemy class.
 * @author VincentLy
 */
public class BossEnemy extends ShootingEnemy{
	
	private Timer creation;
	private int n = 20;
	
	public BossEnemy(float x,float y,int d,Animation a) throws SlickException{
		super(x,y,d,a);
		setHP(20);
		setMaxHP(20);
		creation = new Timer(7500,new ActionListener(){
			public void actionPerformed(ActionEvent e){
				try {
					if(n>0){
						Things.newenemies.add(new ShootingEnemy(400,100,1,anim()));
						n--;
					}	
					else 
						creation.stop();
				} 
				catch (SlickException e1) {System.out.println("Enemy error.");}
			}
		});
	}
	
	/**
	 * Does everything ShootingEnemy does while summoning ShootingEnemy once in a while.
	 * @author VincentLy
	 */
	public void update(){
		super.update();
		creation.start();		
	}
	
	/**
	 * Cleans up the timer as needed
	 * @author VincentLy
	 */
	public void clean(){
		super.clean();
		if(creation!=null)
			creation.stop();
	}
}